package com.jackstraw.jack_base.datasource.common.service;

import com.jackstraw.jack_base.datasource.common.entity.DataSourceRouting;
import com.jackstraw.jack_base.datasource.common.entity.SnowflakeIdGenerator;
import com.jackstraw.jack_base.datasource.common.entity.enums.BusinessNameInterFace;

public interface SnowflakeIdService<DR extends DataSourceRouting> {


    DR getDataSourceRouting();

    /**
     * 获取SnowflakeIdGenerator，若没有初始化，则进行初始化
     *
     * @param businessNameInterFace 业务名称
     * @return
     */
    SnowflakeIdGenerator snowflakeIdGenerator(BusinessNameInterFace businessNameInterFace);

    /**
     * 拿到下一个ID
     *
     * @param businessNameInterFace
     * @return
     */
    default Long nextId(BusinessNameInterFace businessNameInterFace) {
        return this.snowflakeIdGenerator(businessNameInterFace).nextId();
    }

}
